<template>
    <div class="inputContent">
        <t-input v-if="props.type === SearchEnum.INPUT" v-model="value" :placeholder="props.placeholder || $t('common.pl.input')"></t-input>
        <t-textarea v-else-if="props.type === SearchEnum.TEXTAREA" v-model="value"
            :placeholder="props.placeholder || $t('common.pl.input')"></t-textarea>
        <t-select v-else-if="props.type === SearchEnum.SELECT" v-model="value" :placeholder="props.placeholder || $t('common.pl.input')">
            <t-option v-for="(value, key) in radioOptions" :key="key" :value="key" :label="$t(value)" />
        </t-select>
        <!-- <t-select v-else-if="props.type === 'dict'" v-model="value" :placeholder="props.placeholder || '请输入'">
            <t-option v-for="(item, index) in dictOptions" :key="item.dictValue" :value="item.dictValue"
                :label="$t(item.dictLabel)" />
        </t-select> -->
        <SelectDict v-else-if="props.type === SearchEnum.DICT"
            :dictType="dictType"
            v-model:value="value"
            :placeholder="props.placeholder || $t('common.pl.select')"
        />
        <!-- <t-radio-group v-else-if="props.type === 'radio'" v-model="value">
            <t-radio v-for="(value,key) in radioOptions" :key="key" :value="key">{{ value }}</t-radio>
        </t-radio-group> -->
    </div>
</template>
<script setup lang="ts">
import { useVModels } from '@vueuse/core';
import { ComputedRef } from 'vue';
import SelectDict from '@/components/dict/SelectDict.vue'
import { SearchEnum } from '../types';

const props = defineProps<{
    type: SearchEnum,
    value: any,
    placeholder?: string | ComputedRef<string> | any,
    radioOptions?: { [key: string]: string }
    dictType?: string,// 单选项字典
}>()

const emit = defineEmits<{
    (e: 'update:value', value: string): void
}>()

const { value } = useVModels(props, emit)

</script>
<style scoped lang="less"></style>